package com.ruoyi.web.controller.market.extend;

import java.util.List;
import java.util.Map;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.db.domain.ChannelUnionResultInfo;
import com.ruoyi.extend.service.IChannelUnionResultInfoService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.web.wapper.ChannelUnionResultInfoWapper;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 渠道联登结果信息Controller
 * 
 * @author ruoyi
 * @date 2023-06-08
 */
@Controller
@RequestMapping("/extend/UnionResultInfo")
public class ChannelUnionResultInfoController extends BaseController
{
    private String prefix = "extend/UnionResultInfo";

    @Autowired
    private IChannelUnionResultInfoService channelUnionResultInfoService;

    @RequiresPermissions("extend:UnionResultInfo:view")
    @GetMapping()
    public String UnionResultInfo()
    {
        return prefix + "/UnionResultInfo";
    }

    /**
     * 查询渠道联登结果信息列表
     */
    @RequiresPermissions("extend:UnionResultInfo:view")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(ChannelUnionResultInfo channelUnionResultInfo)
    {
        startPage();
        List<Map<String, Object>> mapList = channelUnionResultInfoService.selectChannelUnionResultInfoListMap(channelUnionResultInfo);
        mapList = new ChannelUnionResultInfoWapper(mapList).wrap();
        return getDataTable(mapList);
    }

    /**
     * 导出渠道联登结果信息列表
     */
    @RequiresPermissions("extend:UnionResultInfo:export")
    @Log(title = "渠道联登结果信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(ChannelUnionResultInfo channelUnionResultInfo)
    {
        List<ChannelUnionResultInfo> list = channelUnionResultInfoService.selectChannelUnionResultInfoList(channelUnionResultInfo);
        ExcelUtil<ChannelUnionResultInfo> util = new ExcelUtil<ChannelUnionResultInfo>(ChannelUnionResultInfo.class);
        return util.exportExcel(list, "渠道联登结果信息数据");
    }

    /**
     * 新增渠道联登结果信息
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存渠道联登结果信息
     */
    @RequiresPermissions("extend:UnionResultInfo:add")
    @Log(title = "渠道联登结果信息", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(ChannelUnionResultInfo channelUnionResultInfo)
    {
        return toAjax(channelUnionResultInfoService.insertChannelUnionResultInfo(channelUnionResultInfo));
    }

    /**
     * 修改渠道联登结果信息
     */
    @RequiresPermissions("extend:UnionResultInfo:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        ChannelUnionResultInfo channelUnionResultInfo = channelUnionResultInfoService.selectChannelUnionResultInfoById(id);
        mmap.put("channelUnionResultInfo", channelUnionResultInfo);
        return prefix + "/edit";
    }

    /**
     * 修改保存渠道联登结果信息
     */
    @RequiresPermissions("extend:UnionResultInfo:edit")
    @Log(title = "渠道联登结果信息", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(ChannelUnionResultInfo channelUnionResultInfo)
    {
        return toAjax(channelUnionResultInfoService.updateChannelUnionResultInfo(channelUnionResultInfo));
    }

    /**
     * 删除渠道联登结果信息
     */
    @RequiresPermissions("extend:UnionResultInfo:remove")
    @Log(title = "渠道联登结果信息", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(channelUnionResultInfoService.deleteChannelUnionResultInfoByIds(ids));
    }
}
